package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Tour;
import cn.wolfcode.trip.base.mapper.TourMapper;
import cn.wolfcode.trip.base.query.TourObject;
import cn.wolfcode.trip.base.service.ITourService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TourServiceImpl implements ITourService {

    @Autowired
    private TourMapper mapper;


    @Override
    public Long saveTour(Tour t) {
        mapper.insert(t);
        return t.getId();
    }

    @Override
    public void changeState(Long id) {
        //付钱之后,使得订单变成已付费的状态
        mapper.changeState(id);
    }

    @Override
    public PageInfo query(TourObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), "playTime desc");
        List<Tour> list = mapper.query(qo);
        return new PageInfo(list);
    }
}
